package NC95_数组中的最长连续子序列;

import java.util.*;


public class Solution {
    /**
     * max increasing subsequence
     * @param arr int整型一维数组 the array
     * @return int整型
     */
    public int MLS (int[] arr) {
        // write code here
        if (arr == null || arr.length == 0){
            return 0;
        }
        int res = 1;
        int count = 1;
        Arrays.sort(arr);
        for (int i = 1; i < arr.length; i++){
            if (arr[i] == arr[i - 1]){
                continue;
            }else if (arr[i] - arr[i - 1] == 1){
                count++;
            }else {
                count = 1;
            }
            res = Math.max(res, count);
        }
        return res;
    }
}